<template>
  <el-row class="">
    <el-form label-width="120px" class="form-style" v-for="(item,index) in myValue" :key="index">
      <el-form-item label="权益名称：">
        <el-col :span="20">
          <el-input :value="item" placeholder="请输入权益名称" :maxlength="40" number-word />
        </el-col>
      </el-form-item>
      

      <div class="button-box">
        <el-button type="primary" :loading="loading" native-type="submit" @click="submitForm('form')">保存</el-button>
        <el-button type="primary" :loading="loading" @click="addEquity(index)">+继续添加权益</el-button>
      </div>
    </el-form>
  </el-row>
</template>
<script>
  import {form} from 'utils/mixins'
  import {Input} from '@element-ui'
  export default {
    props: {
      ...Input.props, // 继承Input的所有属性
      formdata: {
        type: Object
      },
      value: {
        type: Array
      },
      minlength: {
        type: Number
      },
      maxlength: {
        type: Number
      }
    },
    mixins: [form],
    watch: {
      value (value) {
        this.myValue = value
      }
    },
    data () {
      let myValue = this.value
      if (!this.value || this.value.length === 0) {
        myValue = ['']
      }
      return {
        myValue,
        loading: false
      }
    },
    methods: {
      addEquity (index) {
        this.myValue.push('')
      }
    }
  }
</script>
